home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text;
-
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.io.OutputStreamWriter;
- import java.io.PrintStream;
- import java.io.PrintWriter;
- import java.io.Serializable;
- import java.io.UnsupportedEncodingException;
- import java.util.Enumeration;
- import javax.swing.tree.TreeNode;
-
- public abstract class AbstractDocument$AbstractElement implements Element, MutableAttributeSet, Serializable, TreeNode {
- // $FF: synthetic field
- private final AbstractDocument this$0;
- private Element parent;
- private transient AttributeSet attributes;
-
- public AbstractDocument$AbstractElement(AbstractDocument var1, Element var2, AttributeSet var3) {
- this.this$0 = var1;
- this.parent = var2;
- this.attributes = var1.getAttributeContext().getEmptySet();
- if (var3 != null) {
- this.addAttributes(var3);
- }
-
- }
-
- public void addAttribute(Object var1, Object var2) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var3 = this.this$0.getAttributeContext();
- this.attributes = var3.addAttribute(this.attributes, var1, var2);
- }
-
- public void addAttributes(AttributeSet var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- this.attributes = var2.addAttributes(this.attributes, var1);
- }
-
- private final void checkForIllegalCast() {
- Thread var1 = this.this$0.getCurrentWriter();
- if (var1 == null || var1 != Thread.currentThread()) {
- throw new StateInvariantError("Illegal cast to MutableAttributeSet");
- }
- }
-
- public abstract Enumeration children();
-
- public boolean containsAttribute(Object var1, Object var2) {
- return this.attributes.containsAttribute(var1, var2);
- }
-
- public boolean containsAttributes(AttributeSet var1) {
- return this.attributes.containsAttributes(var1);
- }
-
- public AttributeSet copyAttributes() {
- return this.attributes.copyAttributes();
- }
-
- public void dump(PrintStream var1, int var2) {
- PrintWriter var3;
- try {
- var3 = new PrintWriter(new OutputStreamWriter(var1, "JavaEsc"), true);
- } catch (UnsupportedEncodingException var8) {
- var3 = new PrintWriter(var1, true);
- }
-
- this.indent(var3, var2);
- if (this.getName() == null) {
- var3.print("<??");
- } else {
- var3.print("<" + this.getName());
- }
-
- if (this.getAttributeCount() > 0) {
- var3.println("");
- Enumeration var4 = this.attributes.getAttributeNames();
-
- while(var4.hasMoreElements()) {
- Object var5 = var4.nextElement();
- this.indent(var3, var2 + 1);
- var3.println(String.valueOf(var5) + "=" + this.getAttribute(var5));
- }
-
- this.indent(var3, var2);
- }
-
- var3.println(">");
- if (this.isLeaf()) {
- this.indent(var3, var2 + 1);
- var3.print("[" + this.getStartOffset() + "," + this.getEndOffset() + "]");
- AbstractDocument.Content var9 = this.this$0.getContent();
-
- try {
- String var11 = var9.getString(this.getStartOffset(), this.getEndOffset() - this.getStartOffset());
- if (var11.length() > 40) {
- var11 = var11.substring(0, 40) + "...";
- }
-
- var3.println("[" + var11 + "]");
- } catch (BadLocationException var7) {
- }
- } else {
- int var10 = this.getElementCount();
-
- for(int var12 = 0; var12 < var10; ++var12) {
- AbstractDocument$AbstractElement var6 = (AbstractDocument$AbstractElement)this.getElement(var12);
- var6.dump(var1, var2 + 1);
- }
- }
-
- }
-
- protected void finalize() throws Throwable {
- AbstractDocument.AttributeContext var1 = this.this$0.getAttributeContext();
- var1.reclaim(this.attributes);
- }
-
- public abstract boolean getAllowsChildren();
-
- public Object getAttribute(Object var1) {
- Object var2 = this.attributes.getAttribute(var1);
- if (var2 == null) {
- AttributeSet var3 = this.parent != null ? this.parent.getAttributes() : null;
- if (var3 != null) {
- var2 = var3.getAttribute(var1);
- }
- }
-
- return var2;
- }
-
- public int getAttributeCount() {
- return this.attributes.getAttributeCount();
- }
-
- public Enumeration getAttributeNames() {
- return this.attributes.getAttributeNames();
- }
-
- public AttributeSet getAttributes() {
- return this;
- }
-
- public TreeNode getChildAt(int var1) {
- return (TreeNode)this.getElement(var1);
- }
-
- public int getChildCount() {
- return this.getElementCount();
- }
-
- public Document getDocument() {
- return this.this$0;
- }
-
- public abstract Element getElement(int var1);
-
- public abstract int getElementCount();
-
- public abstract int getElementIndex(int var1);
-
- public abstract int getEndOffset();
-
- public int getIndex(TreeNode var1) {
- for(int var2 = this.getChildCount() - 1; var2 >= 0; --var2) {
- if (this.getChildAt(var2) == var1) {
- return var2;
- }
- }
-
- return -1;
- }
-
- public String getName() {
- return this.attributes.isDefined("$ename") ? (String)this.attributes.getAttribute("$ename") : null;
- }
-
- public TreeNode getParent() {
- return (TreeNode)this.getParentElement();
- }
-
- public Element getParentElement() {
- return this.parent;
- }
-
- public AttributeSet getResolveParent() {
- AttributeSet var1 = this.attributes.getResolveParent();
- if (var1 == null && this.parent != null) {
- var1 = this.parent.getAttributes();
- }
-
- return var1;
- }
-
- public abstract int getStartOffset();
-
- private final void indent(PrintWriter var1, int var2) {
- for(int var3 = 0; var3 < var2; ++var3) {
- var1.print(" ");
- }
-
- }
-
- public boolean isDefined(Object var1) {
- return this.attributes.isDefined(var1);
- }
-
- public boolean isEqual(AttributeSet var1) {
- return this.attributes.isEqual(var1);
- }
-
- public abstract boolean isLeaf();
-
- private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
- var1.defaultReadObject();
- SimpleAttributeSet var2 = new SimpleAttributeSet();
- StyleContext.readAttributeSet(var1, var2);
- AbstractDocument.AttributeContext var3 = this.this$0.getAttributeContext();
- this.attributes = var3.addAttributes(SimpleAttributeSet.EMPTY, var2);
- }
-
- public void removeAttribute(Object var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- this.attributes = var2.removeAttribute(this.attributes, var1);
- }
-
- public void removeAttributes(Enumeration var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- this.attributes = var2.removeAttributes(this.attributes, var1);
- }
-
- public void removeAttributes(AttributeSet var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- if (var1 == this) {
- this.attributes = var2.getEmptySet();
- } else {
- this.attributes = var2.removeAttributes(this.attributes, var1);
- }
-
- }
-
- public void setResolveParent(AttributeSet var1) {
- this.checkForIllegalCast();
- AbstractDocument.AttributeContext var2 = this.this$0.getAttributeContext();
- if (var1 != null) {
- this.attributes = var2.addAttribute(this.attributes, StyleConstants.ResolveAttribute, var1);
- } else {
- this.attributes = var2.removeAttribute(this.attributes, StyleConstants.ResolveAttribute);
- }
-
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- StyleContext.writeAttributeSet(var1, this.attributes);
- }
- }
-